// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright © 2018-2019 Ariadne Devos
/* sHT -- bug reporting / crashing */

#include <sHT/bugs.h>

#include <stdio.h>
#include <stdlib.h>

__attribute__((nonnull (1)))
_Noreturn
static void
sHT_individual_bug(const char *msg)
{
	/* TODO: we should be phoning the control thread, but as there is
	   no such thing yet ...*/
	(void) dprintf(2, "sHT error: %s\n", msg);
	_Exit(1);
}

void
sHT_bug(const struct sHT_bug_option *options, int code)
{
	while ((options->code != 0) && (options->code != code))
		options++;
	sHT_individual_bug(options->msg);
}
